package com.mark.spring.annotation.life.cycle.predestroy;

import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.context.annotation.ComponentScan;

import javax.annotation.PreDestroy;

/**
 * @Description:  PreDestroy引导类
 * @Author: Mark
 * @CreateDate: 2019/9/17 21:25
 * @Version: 3.00.001
 * @Copyright : 豆浆油条个人非正式工作室
 *
 * @see PreDestroy
 *
 * 总结：在容器销毁Bean之前调用
 */
@ComponentScan(basePackages = {"com.mark.spring.annotation.life.cycle.predestroy"})
public class PreDestroyBootstrap {

    public static void main(String[] args) {
        //加载配置，获取bean
        AnnotationConfigApplicationContext applicationContext = new AnnotationConfigApplicationContext(PreDestroyBootstrap.class);

        /*
         * Singer constructor
         * 九月 17, 2019 9:25:49 下午 org.springframework.context.support.AbstractApplicationContext doClose
         * 信息: Closing org.springframework.context.annotation.AnnotationConfigApplicationContext@6576fe71: startup date [Tue Sep 17 21:25:48 CST 2019]; root of context hierarchy
         * QQ音乐下架了Jay的《说好不哭》
         *
         * 结果表明先执行构造方法 后执行@PreDestroy标注的方法
         */

        //关闭上下文
        applicationContext.close();
    }
}
